#ifndef __RF_DRIVE_H
#define __RF_DRIVE_H

#include <stdint.h>

#define DRIVE_DAC_CTRL_WORD(ctrl, word) (0x80000 | ((uint16_t)(ctrl) << 13) | ((uint16_t)(word) & 0x1fff))
#define DRIVE_DAC_DATA_PACK(addr, data) (((uint16_t)(addr) << 12) | (uint16_t)(data)) // 低位先行
#define DRIVE_SPI_CS_BIT(index) (0x0001 << (index))

typedef enum
{
    kDAC_A,
    KDAC_B,
    kDAC_C,
    kDAC_D,
    kDAC_E,
    kDAC_F,
    kDAC_G,
    kDAC_H,
} dac_addr_t;

typedef enum
{
    kCtrlGAIN,
    kCtrlLDAC,
    kCtrlOFF,
    kCtrlRESET,
} dac_ctrl_bit_t;

typedef enum
{
    kSPI_CS_Source,
    kSPI_CS_DAC1,
    kSPI_CS_DAC2,
    kSPI_CS_Phase1,
    kSPI_CS_Phase2,
    kSPI_CS_Phase3,
    kSPI_CS_Phase4,
    kSPI_CS_Phase5,
    kSPI_CS_Phase6,
    kSPI_CS_Phase7,
    kSPI_CS_Phase8,
    kSPI_CS_Phase9,
} spi_cs_t;

typedef struct
{
    spi_cs_t cs;
    dac_addr_t addr;
    uint16_t value;
} dac_config_t;

typedef struct
{
    spi_cs_t cs;
    uint16_t value;
} rf_source_t;

#endif
